package zry.User;

import zry.Operate.PreliminaryReview;
import zry.Operate.Search;
import zry.User.Teacher.*;

import java.util.Scanner;

public class TeacherUser {
    public void Login(String userid, String userpassword) {
        try {
            TeacherDAO teacherDAO = new TeacherDAOImpl();
            Teacher teacher = teacherDAO.getTeacher(userid, userpassword);//根据id和密码获取teacher
            String teacher_name = teacher.getT_name();//如果teacher不存在，这一步会发生异常，从而输出catch{}中的内容
            System.out.println("欢迎！导师" + teacher);

            while (true) {
                System.out.println("请输入要使用的模块：\n1成果认定系统\n2退出");
                Scanner scanner = new Scanner(System.in);
                String input = scanner.nextLine();
                if (input.equals("1")) {
                    TeacherAchievementSystem(userid);
                } else if (input.equals("2")) {
                    System.out.println("——————————————————————");
                    System.out.println("已退出");
                    break;
                } else {
                    System.out.println("输入错误，请输入1-2的数字");
                }
            }
        } catch (Exception e) {
            System.out.println("用户名或密码错误，请重新输入");
        }
    }

    public void TeacherAchievementSystem(String userid)
    {
        System.out.println("——————————————————————\n欢迎使用成果认定子系统");
        label:
        while (true) {
            System.out.println("——————————————————————\n请输入需要的操作");
            System.out.println("1.查看学生的成果认定情况");
            System.out.println("2.查看某条申请的详细内容");
            System.out.println("3.初审");
            System.out.println("4.退出成果认定子系统");
            Scanner scanner = new Scanner(System.in);
            String input = scanner.nextLine();
            switch (input) {
                case "1":
                    new Search().searchAllMyStudentsAchievement(userid);
                    break;
                case "2":
                    new Search().searchMyStudentsAchievement(userid);
                    break;
                case "3":
                    new PreliminaryReview().PreliminaryReview(userid);
                    break;
                case "4":
                    break label;
                default:
                    System.out.println("输入错误，请重新输入");
                    break;
            }
        }
    }
}
